.toggle {
  position: relative;
  z-index: var(--z-index-1);
  display: flex;
  gap: var(--space-8);
}

.disabled,
.disabled * {
  cursor: not-allowed;
}

.input {
  position: absolute;
  z-index: var(
    --z-index-1
  ); /* stack `.input` over all other elements within `.toggle` */
  top: calc(-1 * var(--space-8));
  right: calc(-1 * var(--space-8));
  bottom: calc(-1 * var(--space-8));
  left: calc(-1 * var(--space-8));
  display: block;
}

.box {
  position: relative;
  width: var(--space-32);
  height: var(--space-16);
  border: var(--border-width-1) solid transparent;
  border-radius: calc(var(--space-16) / 2);
  background-color: var(--figma-color-bg-tertiary);
  transition: background-color var(--transition-duration-100) ease-out;
}
.toggle:not(.disabled) .input:focus-visible ~ .box {
  border-color: var(--figma-color-border-onbrand);
}
.toggle:not(.disabled) .input:checked ~ .box {
  background-color: var(--figma-color-bg-brand);
}
.toggle:not(.disabled) .input:checked:focus ~ .box {
  border-color: var(--figma-color-border-onbrand);
}
.toggle:not(.disabled) .input:checked:focus-visible ~ .box {
  border-color: var(--figma-color-border-onbrand);
  box-shadow: 0 0 0 var(--border-width-1) var(--figma-color-bg) inset;
}
.disabled .input:checked ~ .box {
  background-color: var(--figma-color-bg-disabled);
}

.switch {
  position: absolute;
  top: 0;
  width: calc(var(--space-16) - (2 * var(--border-width-1)));
  height: calc(var(--space-16) - (2 * var(--border-width-1)));
  border-radius: calc((var(--space-16) / 2) - var(--border-width-1));
  background-color: var(--figma-color-icon-onbrand);
  transition: left var(--transition-duration-100) ease-out;
}
.input:not(:checked) ~ .box .switch {
  left: 0;
}
.input:checked ~ .box .switch {
  left: calc(var(--space-32) - var(--space-16));
}

.children {
  flex: 1;
  padding-top: var(--space-4);
  color: var(--figma-color-text);
}
.disabled .children {
  opacity: var(--opacity-30);
}
